import request from '@/utils/request'

const messageService = {
  // 获取所有消息
  getMessages() {
    return request({
      url: '/Messages',
      method: 'get'
    })
  },

  // 根据ID获取消息
  getMessageById(id) {
    return request({
      url: `/Messages/${id}`,
      method: 'get'
    })
  },

  // 创建消息
  createMessage(data) {
    return request({
      url: '/Messages',
      method: 'post',
      data
    })
  },

  // 更新消息
  updateMessage(id, data) {
    return request({
      url: `/Messages/${id}`,
      method: 'put',
      data
    })
  },

  // 删除消息
  deleteMessage(id) {
    return request({
      url: `/Messages/${id}`,
      method: 'delete'
    })
  },

  // 获取用户的消息列表
  getMessagesByUserId(userId) {
    return request({
      url: `/Messages/user/${userId}`,
      method: 'get'
    })
  },

  // 标记消息为已读
  markAsRead(id) {
    return request({
      url: `/Messages/${id}/read`,
      method: 'put'
    })
  },

  // 获取用户未读消息数量
  getUnreadCount(userId) {
    return request({
      url: `/Messages/unread-count/${userId}`,
      method: 'get'
    })
  }
}

export default messageService 